const esbuild = await import('esbuild')

let result

let js = `
{
    "name": "text-pkg"
}
`

result = esbuild.transformSync(js, {
    loader: 'json',
})

console.log(result)

/*
{
  warnings: [],
  code: 'module.exports = {\n  name: "text-pkg"\n};\n',
  map: ''
}
*/

// 1) json 文件默认会转为 cjs 格式输出

result = esbuild.transformSync(js, {
    loader: 'json',
    format: 'esm',
})

console.log(result)

/*
{
  warnings: [],
  code: 'var name = "text-pkg";\n' +
    'var stdin_default = {\n' +
    '  name\n' +
    '};\n' +
    'export {\n' +
    '  stdin_default as default,\n' +
    '  name\n' +
    '};\n',
  map: ''
}
*/

// 1) json 文件设置为 esm 格式输出
